﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows;

namespace Zero.UControl.Base.Helper.Base
{
    internal class RotateCommand : IDrawingCommand
    {
        private readonly UIElement _el;
        private readonly double _a;

        public RotateCommand(UIElement el, double a)
        {
            _el = el;
            _a = a;
        }

        private RotateTransform? _rt;
        public void Execute()
        {
            _rt = _el.RenderTransform as RotateTransform ?? new RotateTransform(0, 0.5, 0.5);
            _el.RenderTransformOrigin = new Point(0.5, 0.5);
            _el.RenderTransform = _rt; _rt.Angle += _a;
        }
        public void UnExecute() { if (_rt != null) _rt.Angle -= _a; }
    }
}
